package view;

import java.util.List;

import model.Contact;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import controller.ContactManager;

public class ContactActionMD extends ActionSupport implements ModelDriven<Contact>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Contact contact = new Contact();
	private ContactManager contactManager;
	private List<Contact> contactList;
	
	public ContactActionMD() {
        contactManager = new ContactManager();
    }
	
	public Contact getContact()	{
		return contact;
	}
	
	public String update() {
    	System.out.println(contact);
    	try {
        	contactManager.update(contact);
        } catch (Exception e) {
            e.printStackTrace();
        }
        this.setContactList(contactManager.list());
        return SUCCESS;
    }

	/**
	 * @return the contactList
	 */
	public List<Contact> getContactList() {
		return contactList;
	}

	/**
	 * @param contactList the contactList to set
	 */
	public void setContactList(List<Contact> contactList) {
		this.contactList = contactList;
	}

	@Override
	public Contact getModel() {
		// TODO Auto-generated method stub
		return null;
	}

	
}
